Embeds: Fix get_site_icon_url() dropping fallback when attachment URL…#11601
Embeds: Fix get_site_icon_url() dropping fallback when attachment URL…#11601Sukhendu2002 wants to merge 14 commits intoWordPress:trunkfrom
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Can we add tests for I see there are existing tests for |
There was a problem hiding this comment.
Pull request overview
Fixes a regression where get_site_icon_url() could drop a provided fallback URL when the attachment URL lookup fails, and updates embed site-title rendering to avoid emitting broken/empty icon attributes.
Changes:
- Preserve the caller-provided fallback URL in
get_site_icon_url()whenwp_get_attachment_image_url()returns false. - Refactor
the_embed_site_title()to conditionally render the site icon markup and omitsrcsetwhen appropriate. - Add PHPUnit coverage for the fallback behavior and embed site title icon output edge cases (attachment URL failure, empty URL, identical 1x/2x URLs, no site icon set).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/phpunit/tests/general/template.php | Adds tests for get_site_icon_url() fallback retention and the_embed_site_title() icon/srcset behaviors. |
| src/wp-includes/general-template.php | Ensures attachment URL failures don’t overwrite a provided fallback URL in get_site_icon_url(). |
| src/wp-includes/embed.php | Adjusts embed site title markup to avoid empty src/broken srcset and to omit the icon when URL is empty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $this->assertTrue( $processor->next_tag( 'IMG' ), 'Expected IMG tag.' ); | ||
| $this->assertSame( $svg_url, $processor->get_attribute( 'src' ), '1x URL should be present in src.' ); |
There was a problem hiding this comment.
| $this->assertTrue( $processor->next_tag( 'IMG' ), 'Expected IMG tag.' ); | |
| $this->assertSame( $svg_url, $processor->get_attribute( 'src' ), '1x URL should be present in src.' ); | |
| $this->assertTrue( $processor->next_tag( 'IMG' ), 'Expected IMG tag.' ); | |
| $this->assertTrue( $processor->has_class( 'wp-embed-site-icon' ), 'Expected IMG to have wp-embed-site-icon class.' ); | |
| $this->assertSame( $svg_url, $processor->get_attribute( 'src' ), '1x URL should be present in src.' ); |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Thanks for the iterations. Changes looks good to me.
Trac ticket: https://core.trac.wordpress.org/ticket/65098
Use of AI Tools
AI assistance: No
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.